﻿@using Microsoft.AspNetCore.Http;
@model IEnumerable<DAMS.Models.Category>

@{
    ViewData["Title"] = "CategoryList";
}

<h1>全部分类列表</h1>

<p>
    <a asp-action="CategoryAdd">添加分类</a> | <a asp-action="CategoryList" asp-route-type="@(this.Context.Request.Query["type"]=="1"?"0":"1")">查看@(this.Context.Request.Query["type"] == "1" ? "全部" : "顶层")分类</a>

</p>
<form asp-action="CategoryMove" method="get">
    <input name="id" />
    <input name="newid" />
    <input type="submit" value="移动" />

</form>
<table class="table">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.ID)
            </th>
            <th>

                @Html.DisplayNameFor(model => model.Name)
            </th>
            <th>
                Left
            </th>
            <th>
                Right
            </th>
            <th>
                @Html.DisplayNameFor(model => model.ParentID)
            </th>

            <th>
                @Html.DisplayNameFor(model => model.Type)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.DeleteFlag)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.CreateTime)
            </th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.ID)
                </td>
                <td>
                    @( "".PadLeft(item.Layer * 2, '　'))
                    @Html.DisplayFor(modelItem => item.Name)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.LeftNum)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.RightNum)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.ParentID)
                </td>

                <td>
                    @Html.DisplayFor(modelItem => item.Type)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DeleteFlag)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.CreateTime)
                </td>
                <td>

                    @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
                    <a asp-action="CategoryDetails" asp-route-id="@item.ID">详细</a> |
                    <a asp-action="CategoryDel" asp-route-id="@item.ID" onclick="return confirm('是否删除？')">删除</a>
                </td>
            </tr>
        }
    </tbody>
</table>
